package BehavioralPattern.Visitor.visitor;

import BehavioralPattern.Visitor.element.CommonEmployee;
import BehavioralPattern.Visitor.element.Manager;

/**
 * @Classname : ConcreteTotalVisitor
 * @Description : 具体访问者——汇总报表
 * @Author : chentianyu
 * @Date 2023/3/12 10:46
 */


public class ConcreteTotalVisitor implements TotalVisitor {

    // 普通员工工资系数
    private final static int COMMON_COEFFICIENT = 2;
    // 管理者工资系数
    private final static int MANAGER_COEFFICIENT = 5;

    // 普通员工薪资总和
    private Integer commonTotalSalary = 0;
    // 管理者薪资总和
    private Integer managerTotalSalary = 0;

    @Override
    public void visit(CommonEmployee commonEmployee) {
        this.commonTotalSalary += commonEmployee.getSalary() * COMMON_COEFFICIENT;
    }

    @Override
    public void visit(Manager manager) {
        this.managerTotalSalary += manager.getSalary() * MANAGER_COEFFICIENT;
    }

    @Override
    public void totalSalary() {
        System.out.println("本公司的月工资总额是：" + (this.commonTotalSalary + this.managerTotalSalary));
    }

}
